class Name < ActiveRecord::Base
  has_many :addresses
  has_many :alternate_names
  
  def self.find_similar_names_to name, options = {:any => false}
    name_condition = options['any'] ? "%#{name}%" : "#{name}%" 
    find( :all, 
          :conditions => ["sdn_name like ?", name_condition],
          :include => [:addresses, :alternate_names])
  end
  
  def all_xml
    to_xml( :include => [:addresses,:alternate_names] )
  end
  
  def address
    addresses[0]
  end
end